﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;
using System.Web.Security;

namespace WebSite.cn
{
    public partial class forget2 : System.Web.UI.Page
    {
        // Fields



        // Methods
        private void Bind()
        {
            DataTable table = SQLAccess.GreatDs("select * from DB_Member where memberid=" + base.Request.QueryString["memberid"] + " and isnull(flag,0)!=2 and videcode='" + base.Request.QueryString["videcode"] + "' and videcode<>''").Tables[0];
            if (table.Rows.Count > 0)
            {
                this.Session["memberid"] = table.Rows[0]["memberid"].ToString();
                this.Session["username"] = table.Rows[0]["memberlogin"].ToString();
            }
            else
            {
                base.Response.Redirect("index.aspx");
                base.Response.End();
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            DataTable table = SQLAccess.GreatDs("select * from DB_Member where memberid=" + base.Request.QueryString["memberid"] + " and isnull(flag,0)!=2 ").Tables[0];
            if (table.Rows.Count > 0)
            {
                SQLAccess.DoSql("update DB_Member set memberpwd='" + FormsAuthentication.HashPasswordForStoringInConfigFile(re.replace(this.password1.Value), "MD5") + "' where memberid=" + base.Request.QueryString["memberid"] + "");
                base.Response.Write("<script language='javascript'>alert('密码修改成功！');window.location.href='account.aspx';</script>");
                base.Response.End();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if ((base.Request.QueryString["memberid"] == null) && (base.Request.QueryString["videcode"] == null))
            {
                base.Response.Redirect("index.aspx");
                base.Response.End();
            }
            if (!base.IsPostBack)
            {
                this.Bind();
            }
        }

     

    }
}